﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DefinitionGen
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] defs = _3_1_3.List();
            //foreach (string def in defs)
            //{
            //    System.Diagnostics.Debug.WriteLine("base.definitionByOpcodeList.Add(PACKETPARSERMAX20.Core.Defines.enOpcodes." + def + ", (PACKETPARSERMAX20.Core.Base.DefinitionBase)(new " + def + "_DEF()));");

            //}
            string template = System.IO.File.ReadAllText(".\\Template.cs");

            foreach (string def in defs)
            {
                string category = def.Substring(0, def.IndexOf("_"));

                string path = string.Format(".\\DEFS\\{0}\\", category);
                if (!System.IO.Directory.Exists(path)) System.IO.Directory.CreateDirectory(path);
                System.IO.StreamWriter sw = new System.IO.StreamWriter(string.Format("{0}{1}_DEF.cs", path, def));
                string data = template.Replace("Template", def + "_DEF");
                sw.Write(data);
                sw.Close();
            }

            string[] files = System.IO.Directory.GetFiles(@"H:\BASE\DEVELOPMENT\MAXTOOLS20\PACKETPARSERMAX20\PACKETPARSERMAX20.Core\WOW\DEFINITIONS\", "*.cs");
            foreach (string file in files)
            {
                string name = System.IO.Path.GetFileName(file);
                string category  = name.Substring(0, name.IndexOf("_"));
                string path = string.Format(@"H:\BASE\DEVELOPMENT\MAXTOOLS20\PACKETPARSERMAX20\PACKETPARSERMAX20.Core\WOW\DEFINITIONS\{0}\", category);
                if (!System.IO.Directory.Exists(path)) System.IO.Directory.CreateDirectory(path);
                string newfile = path + name;
                System.IO.File.Move(file,newfile);
            }
        }
    }
}
